package com.tancire.net.service.impl;

import java.util.List;
import javax.annotation.Resource;

import com.tancire.common.utils.DateUtils;
import org.springframework.stereotype.Service;
import com.tancire.net.mapper.OrderDetailMapper;
import com.tancire.net.domain.OrderDetail;
import com.tancire.net.service.IOrderDetailService;

/**
 * 订单明细Service业务层处理
 *
 * @author chenchao
 * @date 2023-12-02
 */
@Service
public class OrderDetailServiceImpl implements IOrderDetailService {
    @Resource
    private OrderDetailMapper orderDetailMapper;

    /**
     * 查询订单明细
     *
     * @param id 订单明细主键
     * @return 订单明细
     */
    @Override
    public OrderDetail selectOrderDetailById(Long id) {
        return orderDetailMapper.selectOrderDetailById(id);
    }

    /**
     * 查询订单明细列表
     *
     * @param orderDetail 订单明细
     * @return 订单明细
     */
    @Override
    public List<OrderDetail> selectOrderDetailList(OrderDetail orderDetail) {
        return orderDetailMapper.selectOrderDetailList(orderDetail);
    }

    /**
     * 新增订单明细
     *
     * @param orderDetail 订单明细
     * @return 结果
     */
    @Override
    public int insertOrderDetail(OrderDetail orderDetail) {
        orderDetail.setCreateTime(DateUtils.getNowDate());
        return orderDetailMapper.insertOrderDetail(orderDetail);
    }

    /**
     * 修改订单明细
     *
     * @param orderDetail 订单明细
     * @return 结果
     */
    @Override
    public int updateOrderDetail(OrderDetail orderDetail) {
        orderDetail.setUpdateTime(DateUtils.getNowDate());
        return orderDetailMapper.updateOrderDetail(orderDetail);
    }

    /**
     * 批量删除订单明细
     *
     * @param ids 需要删除的订单明细主键
     * @return 结果
     */
    @Override
    public int deleteOrderDetailByIds(Long[] ids) {
        return orderDetailMapper.deleteOrderDetailByIds(ids);
    }

    /**
     * 删除订单明细信息
     *
     * @param id 订单明细主键
     * @return 结果
     */
    @Override
    public int deleteOrderDetailById(Long id) {
        return orderDetailMapper.deleteOrderDetailById(id);
    }

    /**
     * 批量保存订单明细
     *
     * @param detailList
     */
    @Override
    public void saveBatch(List<OrderDetail> detailList) {
        this.orderDetailMapper.saveBatch(detailList);
    }
}
